home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
C
/
Applications
/
MacGzip 1.0
/
source
/
Mac
/
Work.c
< prev
next >
Wrap
Text File
|
1995-09-08
|
2KB
|
95 lines
/*
* Work.c
* (C) SPDsoft, August 29, 1995
*
* A 'to do' work FIFO
*
*/
/*
* THINK_C 8.0 extra includes (Not in MacHeaders)
*/
#include "GzErrors.h"
#include "Work.h"
#define MAX_WORKS 512
/*
* Globals
*/
int w_start = 0; /* -1 */
int w_end = 0;
TWorkHandle Work[MAX_WORKS];
/*
* Prototypes
*/
static int next_w ( int i );
/************************************************************************************
*/
int new_work( short km, short o, Boolean prompt, FSSpec *fs)
{
if ( w_start == ( w_end = next_w ( w_end )))
return kWorkEndErr;
if ( nil == ( Work[w_end] = (TWorkHandle) NewHandle ( sizeof ( TWork )) ))
{
err = MemError();
return kWorkNoMemErr;
}
(*Work[w_end])->KeysMode = km;
(*Work[w_end])->Op = o;
(*Work[w_end])->Prompt = prompt;
(*Work[w_end])->fs = *fs;
return 0;
}
int get_work( short *km, short *o, Boolean *prompt, FSSpec *fs)
{
if ( w_end == w_start )
return kWorkEndErr;
w_start = next_w( w_start );
*km = (*Work[w_start])->KeysMode;
*o = (*Work[w_start])->Op;
*prompt = (*Work[w_start])->Prompt;
*fs = (*Work[w_start])->fs;
DisposeHandle((Handle)Work[w_start]);
err = MemError();
return err;
}
void reset_work(void)
{
err = noErr;
while (( w_end != w_start ) && ( err == noErr ))
{
w_start = next_w( w_start );
DisposeHandle((Handle)Work[w_start]);
err = MemError();
}
w_start = w_end = 0;
}
/************************************************************************************
*/
static int next_w ( int i )
{
if ( ++i == MAX_WORKS )
i = 0;
return i;
}